Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chroma-js

Package Overview
Dependencies
Maintainers
2
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chroma-js

JavaScript library for color conversions

  • 1.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
546K
decreased by-41.77%
Maintainers
2
Weekly downloads
 
Created

What is chroma-js?

chroma-js is a JavaScript library for color conversions and color scales. It provides a wide range of functionalities for color manipulation, including color creation, color scales, color interpolation, and color analysis.

What are chroma-js's main functionalities?

Color Creation

You can create colors using various input formats such as named colors, hex codes, RGB, HSL, etc. The example demonstrates creating a color from a named color and converting it to a hex code.

const chroma = require('chroma-js');
const color = chroma('red');
console.log(color.hex()); // #FF0000

Color Scales

Chroma-js allows you to create color scales that can interpolate between multiple colors. The example shows creating a grayscale scale and getting the color at the midpoint.

const chroma = require('chroma-js');
const scale = chroma.scale(['white', 'black']);
console.log(scale(0.5).hex()); // #808080

Color Interpolation

You can interpolate between two colors using chroma-js. The example demonstrates mixing red and blue to get a purple color.

const chroma = require('chroma-js');
const color1 = chroma('red');
const color2 = chroma('blue');
const interpolatedColor = chroma.mix(color1, color2, 0.5);
console.log(interpolatedColor.hex()); // #800080

Color Analysis

Chroma-js provides methods to analyze colors, such as getting the luminance. The example shows how to get the luminance of the color orange.

const chroma = require('chroma-js');
const color = chroma('orange');
console.log(color.luminance()); // 0.5

Other packages similar to chroma-js

Keywords

FAQs

Package last updated on 27 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc